﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using School.Entities;
using School.Common;

namespace School.Organization
{
    public static class Grade
    {
        private static SchoolEntities db = new SchoolEntities();

        public static ORG_Grade Single(long id)
        {
            var grades = from x in db.ORG_Grade where x.Id == id select x;

            if (grades.Count() > 0)
                return grades.First();
            else
                return null;
        }

        public static void Add(ORG_Grade grade)
        {
            db.AddToORG_Grade(grade);
            db.SaveChanges();
        }

        public static void Update(ORG_Grade grade)
        {
            var g = Single(grade.Id);

            g.Name = grade.Name;
            g.Description = grade.Description;
            g.Code = grade.Code;
            g.Stage_Id = g.Stage_Id;
            db.SaveChanges();
        }
    }
}
